package com.jumi.microservice.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jm.member.common.core.web.domain.AjaxResult;
import com.jumi.microservice.entity.JmAddress;
import com.jumi.microservice.mapper.JmAddressMapper;
import com.jumi.microservice.service.IJmAddressService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 买家地址信息表 服务实现类
 * </p>
 *
 * @author 要挑客户管理团队
 * @since 2020-09-08
 */
@Service
public class JmAddressServiceImpl extends ServiceImpl<JmAddressMapper, JmAddress> implements IJmAddressService {

    @Autowired
    JmAddressMapper mapper;


    @Override
    public Page getPage(Page page, Wrapper wrapper) {
        return mapper.getPage(page,wrapper);
    }

    @Override
    public JmAddress getDefaultAddress(Integer uid) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("uid",uid);
        wrapper.eq("is_default",1);
        JmAddress address = getOne(wrapper);
        return address;
    }

    @Override
    public JmAddress findMaxNotDefaultObj(Integer uid) {
        return mapper.findMaxNotDefaultObj(uid);
    }
}
